package Model;

/*
 * Loan model class, holds the information about loan objects.
 */
public class Loan
{
    // fields
    private int id;
    String borrowDate;
    String period;
    String state;
    Person person;
    Copy copy;
    
    // constructor, also requires specific objects of type Person and Copy, to assosiate it with loan.
    public Loan(int id, String borrowDate, String period, String state, Person person, Copy copy)
    {
        this.id = id;
        this.borrowDate = borrowDate;
        this.period = period;
        this.state = state;
        this.person = person;
        this.copy = copy;
    }
    
    // getters and setters
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getBorrowDate() {
        return borrowDate;
    }

    public void setBorrowDate(String borrowDate) {
        this.borrowDate = borrowDate;
    }

    public String getPeriod() {
        return period;
    }

    public void setPeriod(String period) {
        this.period = period;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public Copy getCopy() {
        return copy;
    }

    public void setCopy(Copy copy) {
        this.copy = copy;
    }
    
    // returns string representation of an information held in object + uniqe information from assosiated person and copy objects.
    public String toString()
    {
        return " | " + id + " | " + borrowDate + " | " + period + " | " + state + " | Borrowed by: " + person.getName() + " | Borrowed copy: " + copy.getSerialNumber() + " | "; 
    }
}
